package hrm.action.system.schedule;

import hrm.action.Action;
import hrm.action.ActionForward;
import hrm.dto.login.LoginDTO;
import hrm.dto.schedule.ScheduleDTO;
import hrm.serviceimple.ScheduleServiceImple;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyMenuScheduleAction implements Action {

	@Override
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) {
		// TODO Auto-generated method stub
		ActionForward actfoward = new ActionForward();
		ScheduleServiceImple schservice = ScheduleServiceImple.getInstance();
		
		List<ScheduleDTO> lists = schservice.getMyScheduleSubstr(getFindId(request));

		request.setAttribute("sLists", lists);
		actfoward.setUrl("schedule");
		return actfoward;
	}

	private String getFindId(HttpServletRequest request) {
		
		String findid = (String)request.getSession().getAttribute("findid");
		if(findid == null){
			findid = ((LoginDTO)request.getSession().getAttribute("login")).getId();
			request.setAttribute("findid", findid);
		}
		return findid;
	}
}
